package cn.easybuy.tool;

import java.util.Arrays;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class AopTransaction {
	
	private Logger logger = Logger.getLogger(AopTransaction.class);
	
	@Around("execution(* cn.smbms.controller..*.*(..))")
	public Object aroundAop(ProceedingJoinPoint jp) throws Throwable {
		logger.info("调用"+jp.getTarget()+"    方法名"+jp.getSignature()+"     参数列表为"+Arrays.toString(jp.getArgs())+"==============");
		
		Object result;
		try {
			result = jp.proceed();
			logger.info("调用"+jp.getTarget()+"    方法名"+jp.getSignature()+"     返回值为"+result+"===========");
			return result;
		} catch (Throwable e) {
			e.printStackTrace();
			logger.info("调用"+jp.getTarget()+"    方法名"+jp.getSignature()+"      发生异常e"+e+"===========");
			throw e;
		}finally {
			logger.info("调用"+jp.getTarget()+"    方法名"+jp.getSignature()+"      执行完毕==========");
		}
		
	}
	
}
